﻿#ifndef __ITEM_H__
#define __ITEM_H__

#include "cocos2d.h"
#include "Map.h"

USING_NS_CC;
enum ItemStatus
{
	STATUS_NONE,
	STATUS_CHANGEED,
};

class Item : public CCSprite
{
public:
	Item(int _ItemEntry,Player* _Owner = nullptr,int _Item_Guid = 0);
	~Item();

	//装备位置
	void DeleteFromDB();
	int GetItemTotalModifyValue(ItemValue _ItemValue);
	ComeFrom GetComeFrom();
	std::string GetItemEquipSlotString();
	std::string GetClassString(ClassID _classid);
	std::string GetItemTotalModifyValueString(ItemValue _ItemValue,int Number);
	int GetBagSlot()															{ return m_BagSlot; }
	void SetSlot(int i)															{ m_BagSlot = i; SaveSlot(); }
	int GetGuid()																{ return m_Guid; }
	ItemSlot GetEquipItemSlot()													{ return m_ItemBaseInfo.Item_Slot; }
	ClassID GetRequireClass()													{ return m_ItemBaseInfo.NeedClass; }
	int GetNeedLevel()															{ return m_ItemBaseInfo.NeedLevel; }
	int GetSellPrice()															{ return m_ItemBaseInfo.SellPrice; }
	int GetBuyPrice()															{ return m_ItemBaseInfo.BuyPrice; }
	int GetItemExchangeCost()													{ return m_ItemBaseInfo.Exchange_Cost; }
	std::string GetName()														{ return m_ItemBaseInfo.Name.c_str(); }
	std::string GetUrl()														{ return m_ItemBaseInfo.Image_Url.c_str(); }
	int GetItemFlag()															{ return m_ItemBaseInfo.Item_Flag; }
	BondingType GetBondingType()												{ return m_ItemBaseInfo.BondingType; }
	int GetItemBaseValue(ItemValue _ItemValue)									{ return m_ItemBaseInfo.ItemValues[_ItemValue]; }
	bool IsSoulBonding()														{ return m_IsBonding; }


private:
	void Create();
	void LoadFromInventoryDB(int _Guid);
	void SaveToDB();
	void SetOwner(Player* pPlayer)			{ m_Owner = pPlayer; }
	virtual void update(float diff);
	void AddToBag();
	void AddToEquipUI();
private:
	void SaveBase();
	void SaveModify();
	void SaveSlot();
	int m_Guid;
	Player* m_Owner;
	bool m_IsBonding;
	//已卷轴强化次数
	int m_ModifyCount;
	int m_BagSlot;
	//Value(加成)
	std::map<ItemPotential, int> PotentialMap;
	std::map<ItemValue, int> ItemModifyValue;
	ItemTemplateStr m_ItemBaseInfo;
	ItemStatus m_ItemStatus;
	int m_Entry;








	//int m_Mana;
	//int m_Heath;
	//int m_Str;
	//int m_Dex;
	//int m_Int;
	//int m_Luk;
	//int m_Att;
	//int m_Magic_Att;
	//int m_Att_Defance;
	//int m_Magic_Defance;
	//int m_MissChance;
	//int m_JumpHigh;
	//int m_MoveSpeed;
	//int m_BossDamage;
	//int m_Defance_Ingnore;
};



#endif